package com.example.spareparts.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.example.spareparts.entity.SupplierEvaluations;
import com.example.spareparts.service.SupplierEvaluationsService;
import java.util.List;

@RestController
@RequestMapping("/api/supplierevaluations")
public class SupplierEvaluationsController {
    @Autowired
    private SupplierEvaluationsService supplierEvaluationsService;
    @GetMapping("/listall")
    public List<SupplierEvaluations> findAllSupplierEvaluations(){
        return supplierEvaluationsService.findAllSupplierEvaluations();
    }
    @PostMapping("/insert")
    public void insertSupplierEvaluations(@RequestBody SupplierEvaluations supplierEvaluations){
        supplierEvaluationsService.insertSupplierEvaluations(supplierEvaluations);
    }
    @PutMapping("/update/{evaluationid}")
    public void updateSupplierEvaluations(@PathVariable Long evaluationid, @RequestBody SupplierEvaluations supplierEvaluations){
        supplierEvaluations.setEvaluationid(evaluationid);
        supplierEvaluationsService.updateSupplierEvaluations(supplierEvaluations);

    }
    @DeleteMapping("/delete/{evaluationid}")
    public void deleteSupplierEvaluations(@PathVariable Long evaluationid){
        supplierEvaluationsService.deleteSupplierEvaluations(evaluationid);
    }
    @GetMapping("/findbyid/{evaluationid}")
    public SupplierEvaluations findSupplierEvaluationsById(@PathVariable Long evaluationid){
        return supplierEvaluationsService.findSupplierEvaluationsById(evaluationid);
    }
    @GetMapping("/findbysupplierid/{supplierid}")
    public List<SupplierEvaluations> findSupplierEvaluationsBySupplierId(@PathVariable Long supplierid){
        return supplierEvaluationsService.findSupplierEvaluationsBySupplierId(supplierid);
    }
}
